#include "cpp_story.h"
#include "calculator.h"

struct CalcCtx {
    Calculator calc;
    double result;
};

STEP_DEF("^I have entered (\d+) into the calculator$")
{
    REGEX_DOUBLE(n);
    CONTEXT(CalcCtx, context);
    context->calc.push(n);
    return true;
}

STEP_DEF("^I press add")
{
    CONTEXT(CalcCtx, context);
    context->result = context->calc.add();
    return true;
}

STEP_DEF("^I press divide")
{
    CONTEXT(CalcCtx, context);
    context->result = context->calc.divide();
    return true;
}

STEP_DEF("^the result should be (.*) on the screen$")
{
    REGEX_DOUBLE(expected);
    CONTEXT(CalcCtx, context);
    CHECK_EQUAL(expected, context->result);
    return true;
}

